package com.yanmaohu.yulia.bean;

/**
 * @author Bright Lee
 */
public final class ExplicitRowValueConstructor implements
        RowValueConstructor,
        RowValueConstructorPredicand,
        RowValueExpression {

    private int beginIndex;
    private int endIndex;
    private boolean row;
    private ValueExpression rowValueConstructorElement;
    private ValueExpressionList rowValueConstructorElementList;
    private Subquery rowSubquery;

    public ExplicitRowValueConstructor(int beginIndex,
                                       int endIndex,
                                       ValueExpressionList rowValueConstructorElementList) {
        this.beginIndex = beginIndex;
        this.endIndex = endIndex;
        this.row = true;
        this.rowValueConstructorElementList = rowValueConstructorElementList;
    }

    public ExplicitRowValueConstructor(int beginIndex,
                                       int endIndex,
                                       ValueExpression rowValueConstructorElement,
                                       ValueExpressionList rowValueConstructorElementList) {
        this.beginIndex = beginIndex;
        this.endIndex = endIndex;
        this.rowValueConstructorElement = rowValueConstructorElement;
        this.rowValueConstructorElementList = rowValueConstructorElementList;
    }

    public ExplicitRowValueConstructor(Subquery rowSubquery) {
        this.beginIndex = rowSubquery.getBeginIndex();
        this.endIndex = rowSubquery.getEndIndex();
        this.rowSubquery = rowSubquery;
    }

    @Override
    public int getBeginIndex() {
        return beginIndex;
    }

    @Override
    public int getEndIndex() {
        return endIndex;
    }

    public boolean isRow() {
        return row;
    }

    public ValueExpression getRowValueConstructorElement() {
        return rowValueConstructorElement;
    }

    public ValueExpressionList getRowValueConstructorElementList() {
        return rowValueConstructorElementList;
    }

    public Subquery getRowSubquery() {
        return rowSubquery;
    }

}
